package com.bzframework.pro.example.socket;

import com.bzframework.pro.socket.MessagingRequest;
import com.bzframework.pro.socket.provider.SubscriptionProvider;
import org.springframework.stereotype.Component;
import reactor.core.publisher.Flux;

import java.time.Duration;

/**
 * @Author bingzhong
 * @Date 2024/11/21 14:09
 * @Description
 */
@Component
public class ExampleProvider implements SubscriptionProvider {

    @Override
    public String id() {
        return "example-provider";
    }

    @Override
    public String name() {
        return "example-provider";
    }

    @Override
    public String[] getTopicPattern() {
        return new String[]{
                "/example/provider"
        };
    }

    @Override
    public Flux<?> subscribe(MessagingRequest request) {
        return Flux.interval(Duration.ofSeconds(3))
                .map(i -> "Hello world: " + i);
    }
}
